<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>黑马旅游-搜索</title>
    <link rel="stylesheet" type="text/css" href="css/common.css">
    <link rel="stylesheet" href="css/search.css">
    <script src="js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="js/getParameter.js"></script>
    <script>
        $(function () {
            //获取?之后包含?所有字符。例 search=?cid=1
            /*var search = location.search;
            //按照=进行切割，选择第二个字符串
            var cid = search.split("=")[1];*/
            var cid = getParameter("cid");
            var rname=getParameter("rname");
            //判断rname如果不为null或者""
            if(rname){
                //url解码
                rname=window.decodeURIComponent(rname);
            }else{
                rname=""
            }
            //加载完成后执行方法，发送异步请求
            load(cid,1,rname);

        })
         function load(cid,currentPage,rname) {
            if (currentPage<1){
             currentPage=1;
            }
            $.get("route/pageQuery",{"cid":cid,"currentPage":currentPage,"rname":rname},function (data) {
                //显示10个页码（前5后4）
                var start;
                var end;
                //如果总数小于10
                if (data.totalPage<10){
                    start=1;
                    end=data.totalPage;
                }else{
                    //前5后4的规则
                    start=data.currentPage-5;
                    end=data.currentPage+4;
                    //如果前面不足5个
                    if (data.currentPage<=5){
                        start=1;
                        end=10;
                    }
                    //如果后面数字越界
                    if (end>data.totalPage){
                        start=data.totalPage-9;
                        end=data.totalPage;
                    }
                }
                //页码显示部分
                $("#totalPage").html(data.totalPage);
                $("#totalCount").html(data.totalCount);
/*                if (currentPage>data.totalCount){
                    currentPage=data.totalCount;
                }*/
                //显示各页的页码
                var lis="";
                lis+='<li onclick="load('+cid+','+1+',\''+rname+'\')"><a href="javascript:void(0)">首页</a></li>';
                lis+='<li class="threeword" onclick="load('+cid+','+(currentPage-1)+',\''+rname+'\')"><a href="javascript:void(0)">上一页</a></li>'
                for (var i = start; i <= end; i++) {
                    //是否为当前的页码，如果是添加css背景颜色
                    if (i==currentPage){
                        lis+='<li onclick="load('+cid+','+i+',\''+rname+'\')" class="curPage"><a href="javascript:void(0);">'+i+'</a></li>';
                    }else{
                        lis+='<li onclick="load('+cid+','+i+',\''+rname+'\')"><a href="javascript:void(0);">'+i+'</a></li>';
                    }

                }
                var nextPage=currentPage+1;
                //解决下一页越界问题
                if (nextPage>data.totalPage){
                    nextPage=data.totalPage
                }
                lis+='<li class="threeword" onclick="load('+cid+','+nextPage+',\''+rname+'\')"><a href="javascript:void(0);">下一页</a></li>';
                lis+='<li class="threeword" onclick="load('+cid+','+data.totalPage+',\''+rname+'\')"><a href="javascript:void(0);">末页</a></li>';
                $("#route").html(lis);
                $("#list")
                //页面内容的显示
                var list = data.list;
                var route_list=""
                for (var i = 0; i < list.length; i++) {
                    var listElement = list[i];
                    route_list+='<li>\n' +
    '                            <div class="img" id="rimage"><img src="'+listElement.rimage+'" style="width: 299px"></div>\n' +
    '                            <div class="text1">\n' +
    '                                <p>'+listElement.rname+'</p>\n' +
    '                                <br/>\n' +
    '                                <p>'+listElement.routeIntroduce+'</p>\n' +
    '                            </div>\n' +
    '                            <div class="price">\n' +
    '                                <p class="price_num">\n' +
    '                                    <span>&yen;</span>\n' +
    '                                    <span>'+listElement.price+'</span>\n' +
    '                                    <span>起</span>\n' +
    '                                </p>\n' +
    '                                <p><a href="route_detail.html?rid='+listElement.rid+'">查看详情</a></p>\n' +
    '                            </div>\n' +
    '                        </li>'
                }
                $("#list").html(route_list);
                //定位到页面的顶部
                window.scrollTo(0,0);
            });
        }

    </script>
</head>
<body>
<!--引入头部-->
<div id="header"></div>
    <div class="page_one">
        <div class="contant">
            <div class="crumbs">
                <img src="images/search.png" alt="">
                <p>黑马旅行><span>搜索结果</span></p>
            </div>
            <div class="xinxi clearfix">
                <div class="left">
                    <div class="header">
                        <span>商品信息</span>
                        <span class="jg">价格</span>
                    </div>
                    <ul id="list">
                        <!--<li>
                            <div class="img" id="rimage"><img src="images/04-search_03.jpg" alt=""></div>
                            <div class="text1">
                                <p>【减100元 含除夕/春节出发】广州增城三英温泉度假酒店/自由行套票</p>
                                <br/>
                                <p>1-2月出发，网付立享￥1099/2人起！爆款位置有限，抢完即止！</p>
                            </div>
                            <div class="price">
                                <p class="price_num">
                                    <span>&yen;</span>
                                    <span id="price">299</span>
                                    <span>起</span>
                                </p>
                                <p><a href="route_detail.html">查看详情</a></p>
                            </div>
                        </li>
                        <li>
                            <div class="img"><img src="images/04-search_03.jpg" alt=""></div>
                            <div class="text1">
                                <p>浪花朵朵旅行普吉岛丛林飞跃空中飞人探险游中文服务泰国旅游</p>
                                <br/>
                                <p>1-2月出发，网付立享￥1099/2人起！爆款位置有限，抢完即止！</p>
                            </div>
                            <div class="price">
                                <p class="price_num">
                                    <span>&yen;</span>
                                    <span>899</span>
                                    <span>起</span>
                                </p>
                                <p><a href="route_detail.html">查看详情</a></p>
                            </div>
                        </li>
                        <li>
                            <div class="img"><img src="images/04-search_03.jpg" alt=""></div>
                            <div class="text1">
                                <p>黑妞皇家旅行普吉岛攀牙湾大船星光之旅皮划艇日落休闲特色体验</p>
                                <br/>
                                <p>1-2月出发，网付立享￥1099/2人起！爆款位置有限，抢完即止！</p>
                            </div>
                            <div class="price">
                                <p class="price_num">
                                    <span>&yen;</span>
                                    <span>999</span>
                                    <span>起</span>
                                </p>
                                <p><a href="route_detail.html">查看详情</a></p>
                            </div>
                        </li>
                        <li>
                            <div class="img"><img src="images/04-search_03.jpg" alt=""></div>
                            <div class="text1">
                                <p>浪花朵朵旅行普吉岛皇帝岛珊瑚岛香蕉船拖拽伞水上项目</p>
                                <br/>
                                <p>1-2月出发，网付立享￥1099/2人起！爆款位置有限，抢完即止！</p>
                            </div>
                            <div class="price">
                                <p class="price_num">
                                    <span>&yen;</span>
                                    <span>99</span>
                                    <span>起</span>
                                </p>
                                <p><a href="route_detail.html">查看详情</a></p>
                            </div>
                        </li>
                        <li>
                            <div class="img"><img src="images/04-search_03.jpg" alt=""></div>
                            <div class="text1">
                                <p>环游记 泰国清迈Lila massage女子监狱spa 丽菈泰式按摩马杀鸡</p>
                                <br/>
                                <p>1-2月出发，网付立享￥1099/2人起！爆款位置有限，抢完即止！</p>
                            </div>
                            <div class="price">
                                <p class="price_num">
                                    <span>&yen;</span>
                                    <span>199</span>
                                    <span>起</span>
                                </p>
                                <p><a href="route_detail.html">查看详情</a></p>
                            </div>
                        </li>
                        <li>
                            <div class="img"><img src="images/04-search_03.jpg" alt=""></div>
                            <div class="text1">
                                <p>【减100元 含除夕/春节出发】广州增城三英温泉度假酒店/自由行套票</p>
                                <br/>
                                <p>1-2月出发，网付立享￥1099/2人起！爆款位置有限，抢完即止！</p>
                            </div>
                            <div class="price">
                                <p class="price_num">
                                    <span>&yen;</span>
                                    <span>899</span>
                                    <span>起</span>
                                </p>
                                <p><a href="route_detail.html">查看详情</a></p>
                            </div>
                        </li>
                        <li>
                            <div class="img"><img src="images/04-search_03.jpg" alt=""></div>
                            <div class="text1">
                                <p>【减100元 含除夕/春节出发】广州增城三英温泉度假酒店/自由行套票</p>
                                <br/>
                                <p>1-2月出发，网付立享￥1099/2人起！爆款位置有限，抢完即止！</p>
                            </div>
                            <div class="price">
                                <p class="price_num">
                                    <span>&yen;</span>
                                    <span>1199</span>
                                    <span>起</span>
                                </p>
                                <p><a href="route_detail.html">查看详情</a></p>
                            </div>
                        </li>
                        <li>
                            <div class="img"><img src="images/04-search_03.jpg" alt=""></div>
                            <div class="text1">
                                <p>泰国芭提雅三合一日游芭提雅蒂芬妮人妖秀成人门票bigeye含接送</p>
                                <br/>
                                <p>1-2月出发，网付立享￥1099/2人起！爆款位置有限，抢完即止！</p>
                            </div>
                            <div class="price">
                                <p class="price_num">
                                    <span>&yen;</span>
                                    <span>1589</span>
                                    <span>起</span>
                                </p>
                                <p><a href="route_detail.html">查看详情</a></p>
                            </div>
                        </li>-->
                    </ul>
                    <div class="page_num_inf">
                        <i></i> 共
                        <span id="totalPage"></span>页<span id="totalCount"></span>条
                    </div>
                    <div class="pageNum">
                        <ul id="route"><!--
                            <li><a href="">首页</a></li>
                            <li class="threeword"><a href="#">上一页</a></li>
                            <li><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">4</a></li>
                            <li><a href="#">5</a></li>
                            <li><a href="#">6</a></li>
                            <li><a href="#">7</a></li>
                            <li><a href="#">8</a></li>
                            <li><a href="#">9</a></li>
                            <li><a href="#">10</a></li>
                            <li class="threeword"><a href="javascript:;">下一页</a></li>
                            <li class="threeword"><a href="javascript:;">末页</a></li>-->
                        </ul>
                    </div>
                </div>
                <div class="right">
                    <div class="top">
                        <div class="hot">HOT</div>
                        <span>热门推荐</span>
                    </div>
                    <ul>
                        <li>
                            <div class="left"><img src="images/04-search_09.jpg" alt=""></div>
                            <div class="right">
                                <p>清远新银盏温泉度假村酒店/自由行套...</p>
                                <p>网付价<span>&yen;<span>899</span>起</span>
                                </p>
                            </div>
                        </li>
                        <li>
                            <div class="left"><img src="images/04-search_09.jpg" alt=""></div>
                            <div class="right">
                                <p>清远新银盏温泉度假村酒店/自由行套...</p>
                                <p>网付价<span>&yen;<span>899</span>起</span>
                                </p>
                            </div>
                        </li>
                        <li>
                            <div class="left"><img src="images/04-search_09.jpg" alt=""></div>
                            <div class="right">
                                <p>清远新银盏温泉度假村酒店/自由行套...</p>
                                <p>网付价<span>&yen;<span>899</span>起</span>
                                </p>
                            </div>
                        </li>
                        <li>
                            <div class="left"><img src="images/04-search_09.jpg" alt=""></div>
                            <div class="right">
                                <p>清远新银盏温泉度假村酒店/自由行套...</p>
                                <p>网付价<span>&yen;<span>899</span>起</span>
                                </p>
                            </div>
                        </li>
                        <li>
                            <div class="left"><img src="images/04-search_09.jpg" alt=""></div>
                            <div class="right">
                                <p>清远新银盏温泉度假村酒店/自由行套...</p>
                                <p>网付价<span>&yen;<span>899</span>起</span>
                                </p>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <!--引入头部-->
    <div id="footer"></div>
    <!--导入布局js，共享header和footer-->
    <script type="text/javascript" src="js/include.js"></script>
</body>

</html>